package com.entity;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by Administrator on 2015/7/22.
 */
@Entity
public class Street {
    private int streetId;
    private String streetName;
    private Set<House> houses;
    private District district;

    @Id
    @Column(name = "street_id")
    public int getStreetId() {
        return streetId;
    }

    public void setStreetId(int streetId) {
        this.streetId = streetId;
    }

    @Basic
    @Column(name = "street_name")
    public String getStreetName() {
        return streetName;
    }

    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Street street = (Street) o;

        if (streetId != street.streetId) return false;
        if (streetName != null ? !streetName.equals(street.streetName) : street.streetName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = streetId;
        result = 31 * result + (streetName != null ? streetName.hashCode() : 0);
        return result;
    }

    @OneToMany(mappedBy = "street")
    public Set<House> getHouses() {
        return houses;
    }

    public void setHouses(Set<House> houses) {
        this.houses = houses;
    }

    @ManyToOne
    @JoinColumn(name = "district_id", referencedColumnName = "district_id", nullable = false)
    public District getDistrict() {
        return district;
    }

    public void setDistrict(District district) {
        this.district = district;
    }
}
